//
//  ViewController.m
//  STDatePickerViewDemo
//
//  Created by yls on 14-2-25.
//  Copyright (c) 2014年 yls. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    _datePickerView = [STDatePickerView showInView:self.view animated:YES];
    
    UIButton *showBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    showBtn.frame = CGRectMake(0, 60, 120, 40);
    [showBtn setTitle:@"显示日期选择器" forState:UIControlStateNormal];
    CGFloat width = [[UIScreen mainScreen] bounds].size.width;
    showBtn.center = CGPointMake(width/2.0, showBtn.center.y);
    [showBtn addTarget:self action:@selector(showDatePickerView:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:showBtn];
    
    [_datePickerView onShowFinish:^(STDatePickerView *pickerView) {
        NSLog(@"Show Finish");
    }];
    
    [_datePickerView onHideFinish:^(STDatePickerView *pickerView) {
        NSLog(@"Hide Finish");
    }];
    
    [_datePickerView onCancel:^(STDatePickerView *pickerView) {
        NSLog(@"onCancel 取消");
    }];
    
    [_datePickerView onDone:^(STDatePickerView *pickerView){
        NSLog(@"onDone 确定");
    }];
    
    [_datePickerView onDateChanged:^(STDatePickerView *pickerView, NSDate *date) {
        NSLog(@"date changed:%@", date.description);
    }];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)showDatePickerView:(id)sender
{
    [_datePickerView show:YES];
}

@end
